<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 100px;
            height: 100px;
            background-color: red;
        }
    </style>
</head>

<body>
    <div></div>
    <input type="text">
    <script>
        var div = document.querySelector('div');
        var input = document.querySelector('input');

        div.onclick = function () {
            console.log('我被单击了');
        }
        div.ondblclick = function () {
            console.log('我被双击了');
        }
        div.onmousedown = function () {
            console.log('鼠标按下了')
        }
        div.onmouseup = function () {
            console.log('鼠标抬起了')
        }
        div.onmouseenter = function () {
            console.log('鼠标移入了')
        }
        div.onmouseleave = function () {
            console.log('鼠标离开了');
        }
        div.onmousemove = function () {
            console.log('鼠标一直在移动')
        }

        // 键盘按下事件 
        // input.onkeydown = function(){
        //   console.log(event.keyCode,'按下字符code码')

        // }
        // 键盘抬起事件 
        // input.onkeyup = function(){
        //   console.log('我被抬起了');
        // }
        // 持续按下事件
        // input.onkeypress = function(){
        //   console.log('持续按下');
        // }
        // 键盘输入事件 必须使用dom2级事件绑定
        input.addEventListener('textInput', function () {
            console.log(event.data)
        })
    </script>
</body>

</html>